<template>
	<vCommonPage type="1" :title="$route.query.title">
		<div slot="customContent" style="width: 100%">
			<div class="title" style="display: flex;justify-content: space-between;font-size: 3.2rem;">
				<div class="leftDiv"></div>
				<div class="centerDiv">请选择支付方式</div>
				<div class="rigthDiv">患者：{{$store.state.user.userinfo.patientName}}</div>
			</div>
			<div class="conentBox">
				<div class="conentBoxItem" v-for="(item,index) in cardChouseList" @click="gotoChcekIdCard(item)"
					:key="'o'+index">
					<img :src="item.url" class="conentBoxItemImg" />
					<div class="conentBoxItemName">{{item.name}}</div>
				</div>
			</div>
			<Wx v-if="payWxBoxIsSHow" @hidWx="hidWx" @payRes="payRes" :wxSrc="wxSrc" :code="code" ref="wxRef"
				:payWxBoxIsSHow="payWxBoxIsSHow" :totalFee="totalFee"></Wx>
			<Zfb v-if="payZfbBoxIsSHow" @hidZfb="hidZfb" @payRes="payRes" :zfbSrc="zfbSrc" :code="code" ref="zfbRef"
				:payZfbBoxIsSHow="payZfbBoxIsSHow" :totalFee="totalFee">
			</Zfb>
			<Yhk v-if="payByCardBoxIsSHow" @hidYhk="hidYhk" @payRes="payRes" :code="code"></Yhk>
			<vPayRes money="5" title="xx" ref="payResult" :res="res" :code="$route.query.code"
				@openPrintTip="openPrintTip"></vPayRes>
			<vTip v-if="tipText" :tipText="tipText"></vTip>
			<div class="bottomBox">
				<el-button type="primary" class="BtnTextHome" @click="goBack()">返回</el-button>
				<el-button type="primary" class="BtnTextHome" @click="goBackHome()">首页</el-button>
			</div>
			<div v-if="payZfbBoxIsSHow||payWxBoxIsSHow||payByCardBoxIsSHow||payResShow||tipText" class="yiny"
				@click="closeYinying()"></div>
			<!-- 选择自费或者医保支付弹窗 -->
			<vChosePayWay :chosePayWayShow="chosePayWayShow" @closeChosePayWayShow="closeChosePayWayShow" :code="code"
				@commonPayByYb="commonPayByYb" @payRes="payRes"></vChosePayWay>
		</div>
	</vCommonPage>
</template>
<script>
	import {
		MessageBox
	} from "element-ui";
	import Wx from './wx.vue'
	import Zfb from './zfb.vue'
	import Yhk from './yhk.vue'
	import {
		SiupoSlipPrinter,
		IDCardReader,
		IdInfo
	} from '@api/tools/Hardware.js'
	var QRCode = require("qrcode");
	import {
		CallPaymentPlatform, //调用支付平台 预约 挂号
		preSettle, //生成结算订单  门诊缴费
		preAdvance, //生成充值订单  门诊充值
		settleAdvance //预交金成功 通知HIS
	} from "@api/apiBox/pay"
	import {
		registerSuccess, //调用预约挂号成功
		getRegisterInfo,
		registerPre
	} from "@api/apiBox/mzyyAndMzgh"
	import {
		paidOrdersSuccessByMzjf,
		preSettleBatch
	} from "@api/apiBox/mzjf"
	import {
		Printerconf
	} from '@api/tools/rprinter.js'
	import {
		preSettlePack,
		preSettleParse,
		settlePack,
		settleParse
	} from "@api/apiBox/MedInsTradeYn"
	import {
		CallMedInsYn
	} from '@/api/tools/MedInsTradeYn';
	import {
		nucleicAcidPreNucleic
	} from '@api/apiBox/hsyy.js'
	export default {
		name: "mzgh",
		components: {
			Yhk,
			Wx,
			Zfb
		},
		data() {
			return {
				cardChouseList: this.$store.state.terminfo.payConfs,
				//支付框是否显示 支付宝支付
				payZfbBoxIsSHow: false,
				//支付框是否显示 wx支付
				payWxBoxIsSHow: false,
				//时间倒计时对象
				myVar: '',
				//支付名称
				payName: '',
				//银行卡窗口是否开启
				payByCardBoxIsSHow: false,
				password: '',
				//银行卡支付弹出框
				payResShow: false,
				paySuccessOrderTime: 5,
				//支付成功时间对象
				payResultVal: '',
				//银行卡号码
				cardNo: this.$store.state.payCard.cardNo,
				wxSrc: '',
				zfbSrc: '',
				//银行卡充值状态
				res: '',
				code: this.$route.query.code, //mzgh mzjf
				wxMothods: '',
				tipText: '',
				pconf: new Printerconf(), //初始化凭条打印
				totalFee: '',
				paidOrdersSuccessByMzjfRes: {},
				chosePayWayShow: false, //自费或者医保支付弹窗是否打开
				payinfo: {} ,//门诊缴费存储的form 数据
				YB: new CallMedInsYn(),
        hisVisitNo: ''
			};
		},
		methods: {
			//前往示例插卡
			gotoChcekIdCard(item) {
				if (parseInt(item.num) == 1) {
					this.openWx();
				} else if (parseInt(item.num) == 2) {
					this.openZfb();
				} else if (parseInt(item.num) == 3) {
					this.openYhk();
				}
			},
			//微信 1 支付宝 2 银行卡3
			openWx() {
				if (this.$route.query.code == 'mzyy') {
					this.sendPayInfo(1);
				} else if (this.$route.query.code == 'mzgh') {
					this.sendPayInfo(1);
				} else if (this.$route.query.code == 'mzjf') {
					this.sendSettlePaylist(1, 2);
				} else if (this.$route.query.code == 'yjjcz') {
					this.sendSettlePaylist(1, 5);
				} else if (this.$route.query.code == 'hsyy') {
					this.getHsYyErcode(1);
				}
			},
			openZfb() {
				if (this.$route.query.code == 'mzyy') {
					this.sendPayInfo(2);
				} else if (this.$route.query.code == 'mzgh') {
					this.sendPayInfo(2);
				} else if (this.$route.query.code == 'mzjf') {
					this.sendSettlePaylist(2, 2);
				}
				//门诊充值
				else if (this.$route.query.code == 'yjjcz') {
					this.sendSettlePaylist(2, 5);
				} else if (this.$route.query.code == 'hsyy') {
					this.getHsYyErcode(2);
				}
			},
			//打开银行卡界面
			openYhk() {
				if (this.$route.query.code == 'mzyy') {
					if (this.cardNo) {
						this.sendPayInfo(3);
					} else {
						this.$router.push({
							name: "checkYhk",
							query: {
								name: 'mzcz',
								title: this.$route.query.title,
								code: this.$route.query.code
							}
						})
					}
				} else if (this.$route.query.code == 'mzgh') {
					if (this.cardNo) {
						this.sendPayInfo(3);
					} else {
						this.$router.push({
							name: "checkYhk",
							query: {
								name: 'mzcz',
								title: this.$route.query.title,
								code: this.$route.query.code
							}
						})
					}
				} else if (this.$route.query.code == 'mzjf') {
					MessageBox.alert("还未对接!.");
				}

			},
			hidWx() {
				this.payWxBoxIsSHow = false;
			},
			hidZfb() {
				this.payZfbBoxIsSHow = false;
			},
			hidYhk() {
				this.payByCardBoxIsSHow = false;
			},
			//支付结果
			async payRes(res) {
				let code = this.$route.query.code;
				console.log("进入到支付结果接口，业务类型:",code);
				console.log(res);
				//挂号成功调用接口
				if (code == 'mzgh' && res == 'success') {
					let successData = {
						data: {
							regId: this.$store.state.appointment.appointmentInfo.regId,
							queueNo: this.$store.state.appointment.appointmentInfo.queueNo,
							settleDate: this.$store.state.appointment.date,
							orderId: this.$store.state.recipel.erCodeInfo.orderId
						},
						that: this
					}
					//向后端发送 预约挂号成功请求
					const successRest = await registerSuccess(successData);
					let appointmentInfo = this.$store.state.appointment.appointmentInfo;
					appointmentInfo.hISVisitNo = successRest.data.hISVisitNo;
					localStorage.setItem("successRest",JSON.stringify(successRest))
					this.hisVisitNo = successRest.data.hisVisitNo;
					this.$store.dispatch("appointment/updateAppointmentInfo", appointmentInfo); //存储锁单信息
					console.log('this.$store.state.appointment.appointmentInfo', this.$store.state.appointment
						.appointmentInfo)
				}
				//如果锁单成功 并且是门诊预约
				if (code == 'mzyy' && res == 'success') {
					let successData = {
						data: {
							regId: this.$store.state.appointment.appointmentInfo.regId,
							queueNo: this.$store.state.appointment.appointmentInfo.queueNo,
							settleDate: this.$store.state.appointment.date,
							orderId: this.$store.state.recipel.erCodeInfo.orderId
						},
						that: this
					}
					//向后端发送 预约锁号成功请求
					const successRest = await registerPre(successData);
					let appointmentInfo = this.$store.state.appointment.appointmentInfo;
					appointmentInfo.hISVisitNo = successRest.data.hISVisitNo;
          this.hisVisitNo = successRest.data.hisVisitNo;
					this.$store.dispatch("appointment/updateAppointmentInfo", appointmentInfo); //存储锁单信息
					console.log(successRest)
				}
				//如果是门诊缴费成功调用这个接口 通知HIS结算成功
				console.log('data', this.$store.state)
        console.log('进入通知HIS门诊缴费阶段，当前医保状态为：',this.$store.state.user.isYbPay)
				if (code == 'mzjf' && res == 'success' && !this.$store.state.user.isYbPay) {
					let paidOrdersSuccessByMzjfData = {
						data: {
							orderId: this.$store.state.recipel.erCodeInfo.orderId,
							patientId: this.$store.state.user.userinfo.patientId, //患者ID
							totalFee: this.$store.state.recipel.records.amount, //总费用
							billNo: this.$store.state.recipel.records.receiptNo,
							orderType: 2, //1: 挂号 订单   2: 缴费订单3: 处方流转订单  4: 处方流转快递订单5:  预交金充值订单
							// payOrderId: this.$store.state.recipel.erCodeInfo.payOrderId, //第三方返回的平台支付流水号
						},
						that: this
					}
					let _this = this;
					//向后端发送 门诊缴费成功请求
					const paidOrdersSuccessByMzjfRes = await paidOrdersSuccessByMzjf(paidOrdersSuccessByMzjfData);
					if (!paidOrdersSuccessByMzjfRes.data) {
						MessageBox.alert('缴费失败，请去收费窗口退费，然后重新缴费。', {
							confirmButtonText: "确定",
							callback: action => {
								_this.goBackHome();
							}
						});
						return;
					}
					if (paidOrdersSuccessByMzjfRes.data) {
						if (!paidOrdersSuccessByMzjfRes.data.hisBillNo) {
							MessageBox.alert('缴费失败，请去收费窗口退费，然后重新缴费。', {
								confirmButtonText: "确定",
								callback: action => {
									_this.goBackHome();
								}
							});
							return;
						}
					}
					let records = _this.$store.state.recipel.records;
					records.paidOrdersSuccessByMzjfRes = paidOrdersSuccessByMzjfRes.data;
					_this.$store.dispatch("recipel/updateRecordsInfo", records); //存储缴费订单信息
				}
				//如果是预交金充值成功 告诉HIS预交金成功
				if (code == 'yjjcz' && res == 'success') {
					let data = {
						data: {
							orderId: this.$store.state.recipel.erCodeInfo.orderId,
							zycs: this.$store.state.user.userinfo.admissionTimes,
							patientId: this.$store.state.user.userinfo.patientId, //患者ID
						},
						that: this
					}
					const yjjRes = await settleAdvance(data);
					let payInfoRes = this.$store.state.recipel.records;
					payInfoRes.yjjRes = yjjRes.data;
					this.$store.dispatch("recipel/updateRecordsInfo", payInfoRes); //存储余额信息

					console.log('success', this.$store.state.recipel.records)
				}
				console.log(res, '支付回调')
				if (res == '1') {
					this.res = 'success';
				} else {
					this.res = res;
				}
				this.payResShow = true;
				//唤起支付结果组件
				this.$refs.payResult.init();
				this.hidAll();
			},
			//隐藏所有支付框框
			hidAll() {
				this.payByCardBoxIsSHow = false;
				this.payZfbBoxIsSHow = false;
				this.payWxBoxIsSHow = false;
			},
			async getHsYyErcode(code) {
				//预结算
				let data = {
					data: {
						totalFee: this.$store.state.appointment.hsyyInfo.totalFee,
						patientId: this.$store.state.appointment.hsyyInfo.idNo,
						billNo: '核酸预约',
						his_visit_no: '核酸预约',
						payway: code,
						patientName: this.$store.state.appointment.hsyyInfo.patientName
					},
					that:this
				}
				const res = await nucleicAcidPreNucleic(data);
				//存储缴费二维码信息
				this.$store.dispatch("recipel/updateErCodeInfo", res.data);
				console.log(res, '存储缴费二维码信息')
				if (code == 1) {
					this.wxSrc = res.data.qrcode;
					this.payWxBoxIsSHow = true;
					// 查询支付状态
					setTimeout(() => {
						this.$refs.wxRef.searchPayStatusEvent();
					}, 5);
				} else if (code == 2) {
					this.zfbSrc = res.data.qrcode;
					this.payZfbBoxIsSHow = true;
					// 查询支付状态
					setTimeout(() => {
						this.$refs.zfbRef.searchPayStatusEvent();
					}, 5);
				} else if (code == 3) {
					this.payByCardBoxIsSHow = true;
				}

			},
			//向后端发送订单消息 获取支付二维码    缴费充值
			async sendSettlePaylist(code, orderType) {
			  console.log('进入到获取支付二维码方法...',code,orderType);
				let totalFee = 0;
				let selfFee = this.$store.state.recipel.records.amount;
				//判断是否进行过医保pay 如果之前付过钱就使用自费金额字段 医保全额支付不会走这里
				if (this.$store.state.user.isYbPay) {
          console.log('当前为医保结算')
					selfFee = this.$store.state.user.userpay;
					this.totalFee = selfFee;
					let records = this.$store.state.recipel.records;
					records.amount = selfFee;
					this.$store.dispatch("recipel/updateRecordsInfo", records); //存储缴费订单信息
					totalFee = this.$store.state.user.userAllPay;
				}else{
					totalFee = this.$store.state.recipel.records.amount;
				}
				this.$store.dispatch("user/updatechargefee", this.$store.state.recipel.records.amount); //支付金额  总费用
				//输出订单消息
				console.log(this.$store.state.recipel.records)
				let payinfo = {
					data: {
						patientId: this.$store.state.user.userinfo.patientId, //患者ID
						termId: this.$store.state.terminfo.terminfo.termId, //终端ID
						totalFee: totalFee, //总费用
						orderType: orderType, //1: 挂号 订单   2: 缴费订单 3: 处方流转订单  4: 处方流转快递订单 5:  预交金充值订单
						selfFee: selfFee,
						payWay: code, //支付渠道 1 微信 2 支付宝 3 银行卡
						billNo: this.$store.state.recipel.records.receiptNo,
						zycs: this.$store.state.user.userinfo.admissionTimes,
						hisVisitNo: this.$store.state.recipel.records.billNo,
						receiptNos: this.$store.state.recipel.records.receiptNos,
						patientName: this.$store.state.user.userinfo.patientName //患者姓名
					},
					that: this
				}
				this.payinfo = payinfo;
				console.log(JSON.stringify(payinfo.data))
				let res = "";
				//预结算 获取二维码 缴费订单
				if (orderType == 2) {
					res = await preSettleBatch(payinfo);
				}
				if (orderType == 5) {
					res = await preAdvance(payinfo);
				}
				//存储缴费二维码信息
				this.$store.dispatch("recipel/updateErCodeInfo", res.data);
				console.log(res, '存储缴费二维码信息')
				if (code == 1) {
					this.wxSrc = res.data.qrcode;
					this.payWxBoxIsSHow = true;
					// 查询支付状态
					setTimeout(() => {
						this.$refs.wxRef.startPay();
					}, 100);
				} else if (code == 2) {
					this.zfbSrc = res.data.qrcode;
					this.payZfbBoxIsSHow = true;
					// 查询支付状态
					setTimeout(() => {
						this.$refs.zfbRef.startPay();
					}, 100);
				} else if (code == 3) {
					this.payByCardBoxIsSHow = true;
				}
			},
			//向后端发送订单消息 获取支付二维码  支付渠道 1 微信 2 支付宝 3 银行卡  预约挂号  预约挂号
			async sendPayInfo(code) {
				let payinfo = {
					data: {
						// body: this.$route.query.title + this.$store.state.appointment.appointmentInfo.regDetailVo
						// 	.deptName, //商品描述信息
						objectId: this.$store.state.appointment.appointmentInfo.regId,
						payWay: code, //支付渠道
						hospitalId: this.$store.state.terminfo.hospId, //医院id
						orderId: this.$store.state.appointment.appointmentInfo.orderId, //订单id
						orderType: this.$store.state.appointment.appointmentInfo.regDetailVo.orderType, //订单类型
						status: this.$store.state.appointment.appointmentInfo.regDetailVo.status, //支付状态
						subject: this.$route.query.title, //商品标题
						cardNo: this.$store.state.user.userinfo.idNo, //身份证号码
						patientName: this.$store.state.user.userinfo.patientName //患者姓名
					},
					that: this
				}
				const res = await CallPaymentPlatform(payinfo);
				//存储缴费二维码信息
				this.$store.dispatch("recipel/updateErCodeInfo", res.data);
				console.log(res, '存储缴费二维码信息')
				if (code == 1) {
					this.wxSrc = res.data.qrcode;
					this.payWxBoxIsSHow = true;
					// 查询支付状态
					setTimeout(() => {
						this.$refs.wxRef.searchPayStatusEvent();
					}, 5);
				} else if (code == 2) {
					this.zfbSrc = res.data.qrcode;
					this.payZfbBoxIsSHow = true;
					// 查询支付状态
					setTimeout(() => {
						this.$refs.zfbRef.searchPayStatusEvent();
					}, 5);
				} else if (code == 3) {
					this.payByCardBoxIsSHow = true;
				}
			},
			//关闭弹窗
			closeYinying() {
				if (this.tipText != '') {
					let _this = this;
					this.tipText = "";
					_this.$confirm('是否跳回首页？', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						setTimeout(() => {
							this.$router.push('/');
						}, 1000);
					}).catch(() => {});
				}
				this.payResShow = false;
				// this.payByCardBoxIsSHow = false;
				// if (this.payWxBoxIsSHow) {
				// 	this.payWxBoxIsSHow = false;
				// 	this.$refs.wxRef.closePay();
				// }
				// if (this.payZfbBoxIsSHow) {
				// 	this.payZfbBoxIsSHow = false;
				// 	this.$refs.zfbRef.closePay();
				// }
				//判断成功弹窗是否开启
				if (this.$refs.payResult.returnIsShow()) {
					this.$refs.payResult.openImmideaty();
				}
				this.$refs.payResult.hidBox();
			},
			//1:报告打印机,2:凭条打印机,3:身份证读卡器
			async openPrintTip() {
				//获取全部报告详情 点击全部打印
				this.closeYinying();
				let code = this.$route.query.code;
        console.log("进入打印方法...",code);
        localStorage.setItem("hisVisitNo",this.hisVisitNo)
				if (code == 'mzyy') {
					//获取打印凭条接口
					let registerData = {
						data: {
							queueNo: this.$store.state.appointment.appointmentInfo.queueNo
						},
						that: this
					}
					const registerInfo = await getRegisterInfo(registerData);
					console.log(registerInfo, 'registerInfo')
					console.log(this.$store.state, '打印')
					console.log('val.$store.state.appointment.appointmentInfo', this.$store.state.appointment
						.appointmentInfo)
					// this.tipText = '您的预约凭证正在打印，请领取后再离开……';
					let printdata = {
						name: this.getPrintDeviceNameByPort('2'),
						data: registerInfo,
            hisVisitNo: this.hisVisitNo
					}
					console.log(this.getPrintNameByPort("2"))
					await this.pconf.mzyyprint(this.getPrintNameByPort("2"), this, printdata).then(res => {
						console.log(res)
						this.tipText = '预约凭证已打印，感谢您的使用！';
						setTimeout(() => {
							this.$router.push('/');
						}, 3000);
					}).catch(e => {
						console.log(e)
						this.tipText = '抱歉，预约凭证打印失败，请联系管理员……';
					});
				} else if (code == 'mzgh') {
					// this.tipText = '您的挂号凭证正在打印，请领取后再离开……';
					//获取打印凭条接口
					let registerData = {
						data: {
							queueNo: this.$store.state.appointment.appointmentInfo.queueNo
						},
						that: this
					}
					const registerInfo = await getRegisterInfo(registerData);
					console.log(registerInfo, 'registerInfo')
					console.log(this.$store.state, '打印')
					// this.tipText = '您的预约凭证正在打印，请领取后再离开……';
					let printdata = {
						name: this.getPrintDeviceNameByPort('2'),
						data: registerInfo,
            hisVisitNo: this.hisVisitNo
					}
					await this.pconf.mzghprint(this.getPrintNameByPort("2"), this, printdata).then(res => {
						console.log(res)
						this.tipText = '挂号凭证已打印，感谢您的使用！';
						setTimeout(() => {
							this.$router.push('/');
						}, 3000);
					}).catch(e => {
						console.log('抱歉，门诊缴费凭证打印失败，请联系管理员……')
						this.tipText = '抱歉，挂号凭证打印失败，请联系管理员……';
					});
				} else if (code == 'mzjf') {
					//如果是医保支付的话并且结算完现金 需要通知his医保结算  现金支付不为0
					console.log('个人支付金额:', this.$store.state.user.userpay)
					if (this.$store.state.user.isYbPay && this.$store.state.user.userpay > 0) {
						console.log('使用医保支付，并且使用微信支付宝支付 通知his。')
						this.payinfo.data.orderId = this.$store.state.recipel.erCodeInfo.orderId;
						this.payinfo.data.IPatientId = this.$store.state.user.IPatientId; //医保个人编号
						this.payinfo.data.IVisitNo = this.$store.state.user.IVisitNo;  //医保流水号
						let  settlePackRes =  await settlePack(this.payinfo);
						console.log("医保结算入参：");
						console.log(settlePackRes.data);
						//唤醒医保组件
						var settleRtn = await this.YB.Trade('BMZJF002', settlePackRes.data);
						console.log("调用医保机器返回：",settleRtn);
						let settleParseItemData = typeof settleRtn == "string" ? JSON.parse(settleRtn) : {};
						console.log("调用医保机器返回解析：",settleParseItemData);
						//获取自费金额
						let settleParseData = {
							data: settleParseItemData,
							that: this
						}
						let settleParseRes = await settleParse(settleParseData);
						let records = this.$store.state.recipel.records;
						records.paidOrdersSuccessByMzjfRes = settleParseRes.data;
						this.$store.dispatch("recipel/updateRecordsInfo", records); //存储缴费订单信息
					}
					// this.tipText = '您的门诊缴费凭证正在打印，请领取后再离开……';
					console.log(this.$store.state, '请领取后再离开')
					let printdata = {
						name: this.getPrintDeviceNameByPort('2'),
						paidOrdersSuccessByMzjfRes: this.paidOrdersSuccessByMzjfRes
					}
					await this.pconf.mzjsprint(this.getPrintNameByPort("2"), this, printdata).then(res => {
					  console.log('打印结算，打印结果：')
						console.log(res)
						this.tipText = '门诊缴费凭证已打印，感谢您的使用！';
						setTimeout(() => {
							this.$router.push('/');
						}, 3000);
					}).catch(e => {
						this.tipText = '抱歉，门诊缴费凭证打印失败，请联系管理员……';
					});
				} else if (code == 'yjjcz') {
					// this.tipText = '您的门诊充值凭证正在打印，请领取后再离开……';
					console.log(this.$store.state, '请领取后再离开')
					let printdata = {
						name: this.getPrintDeviceNameByPort('2'),
						data: {
							// balance: this.$store.state.recipel.records.amount + this.$store.state.user.userinfo.balance
						}
					}
					await this.pconf.zyczprint(this.getPrintNameByPort("2"), this, printdata).then(res => {
						console.log(res)
						this.tipText = '住院充值凭证已打印，感谢您的使用！';
						setTimeout(() => {
							this.$router.push('/');
						}, 3000);
					}).catch(e => {
						console.log(e)
						this.tipText = '抱歉，门诊充值凭证打印失败，请联系管理员……';
					});
				}
			},
			//获取打印机名称
			getPrintDeviceNameByPort(devtype) {
				let term = this.$store.state.terminfo.deviceConfs;
				console.log(term, 'name')
				for (let item of term) {
					console.log(item)
					if (item.deviceType == devtype) {
						return item.deviceName;
					}
				}
				return "";
			},
			//获取打印机型号
			getPrintNameByPort(devtype) {
				let term = this.$store.state.terminfo.deviceConfs;
				console.log(term, 'name')
				for (let item of term) {
					console.log(item)
					if (item.deviceType == devtype) {
						return item.deviceModel;
					}
				}
				return "";
			},
			//关闭弹窗
			closeChosePayWayShow() {
				this.chosePayWayShow = false;
			},
			//医保付完钱了 调用一次正常支付 现在只支持门诊结算业务
			commonPayByYb() {
				if (this.$route.query.code == 'mzjf') {
					this.sendSettlePaylist(1, 2);
				}
			}
		},

		mounted() {},
		created() {
			this.code = this.$route.query.code;
			let code = this.code;
			console.log(this.$store.state, '!!!!!!!!!!')
			if (code == 'mzyy' || code == 'mzgh') {
				this.totalFee = this.$store.state.appointment.appointmentInfo.regDetailVo.totalFee;
				//存储统一的支付费用
				this.$store.dispatch("user/updatechargefee", this.totalFee);
			} else if (code == 'mzjf' || code == 'yjjcz') {
				this.totalFee = this.$store.state.recipel.records.amount;
				//存储统一的支付费用
				this.$store.dispatch("user/updatechargefee", this.totalFee);
			}
			this.cardNo = this.$store.state.payCard.cardNo;
			//如果银行卡号码存在则直接输入银行卡密码
			if (this.cardNo) {
				this.openYhk();
			}

			// if (code == 'mzjf' && this.$store.state.terminfo.ipAddress == '192.168.12.25') {
			// 	this.chosePayWayShow = true;
			// }
			//解除IP限制
			if (code == 'mzjf' ) {
				this.chosePayWayShow = true;
			}

		},
		beforeDestroy() {}
	};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
	@import "../../assets/css/xzzffs.scss";
</style>
